Imperative languages are generally based on fully specified and fully controlled manipulation of named data in a step-wise fashion. These languages include a data declaration that binds a name to a type and possibly to a value, wherein typical basic types are integers, characters and real numbers. New types can be made using type constructors, for example, enumerations, arrays and records. Types are name-equivalent if they have the same names, and structure-equivalent if they have the same values and allow the same operations. Coersions and casts allow minor evasions of the type system.
Two features in a language are orthogonal if they can be combined freely without restricting each other in any way, whereas internal states can be modified through assignment statements, external state through output statements and values derived from expressions. The main flow-control mechanisms are sequencing, selection, repetition, and routine invocation whereby run-time errors can be caught by using signals and exceptions, for example. In program construction, four levels of hierarchy can be distinguished: blocks, routines, modules/packages and programs. Scope rules determine which declaration or declarations define a given name, and if more than one declaration is identified, contextual scope rules are employed to disambiguate. Procedures do not yield a value, functions do, and operators are different notation for functions. The main parameter passing mechanisms are call by value and call by reference.
A module defines an interface, represented by its specification part, whereas an implementation part is separate and hidden from the interface user. In principle, a separate representation part is needed, but this is generally included in the specification part. An abstract data type (ADT) is a named data type defined solely through routines for creating, manipulating and deleting values of that data type; all internal structure is hidden from the user. It differs from a module in that a module contains a type definition from which items can be declared, whereas an ADT is a type that is used directly to declare items. A generic X-unit is a template to derive X-units from, whereas a derivation process is called instantiation. Generic units can also be parameterized. Final program composition is generally performed using a system linker.
In mathematics a ZF set comprehension that describes a set of squares of the odd numbers drawn from some source set A is typically written as:{a2|aεA^odd(a)}.This mathematical notation has a very strong operation reading: for each element a in the set A, if a is odd, then add a squared to the result.
Because of the conciseness and expressive power of this notation, combined with the fact that comprehensions have a natural operation interpretation, several programming languages (starting with the functional languages KRC, Miranda, Haskell, and most recently Python) have adopted variants of the ZF notation as a programming notation to generate lists (or sets) of values. Mathematicians and computer scientist also discovered that the same comprehension notation can also be used to describe queries on both relational data-bases as well as on semi-structured, XML data. In fact, it is possible to interpret comprehensions for a wide range of mathematical structures, called monoids, or more generally monads. This implies that when users define the appropriate monadic structure, they can overload the same comprehension notation to create values in that domain. Examples of monads include state, exceptions, parsers, non-determinism, input-output, and so forth. Unfortunately, these type of comprehensions are not generalized in form and are generally described as fixed structures. Thus, the full power of these type notations are not currently being exploited.